package com.hzpd.hainan.module.usercenter.acticity;



import android.content.Intent;
import android.os.PersistableBundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.hzpd.hainan.R;
import com.hzpd.hainan.api.InterfaceJsonfile;
import com.hzpd.hainan.app.BaseActivity;
import com.hzpd.hainan.app.ToolBarActivity;
import com.hzpd.hainan.module.usercenter.fragment.FindbackpwFragment;
import com.hzpd.hainan.module.usercenter.fragment.LoginFragment;
import com.hzpd.hainan.module.usercenter.fragment.RegisterFragment;

public class LoginActivity extends ToolBarActivity {
    private LoginFragment loginFragment;
    private RegisterFragment registerFragment;
    private FindbackpwFragment findbackpwFragment;

    private FragmentManager fm;
    private Fragment currentFm;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setToolBarVisiable(false);
        fm=getSupportFragmentManager();
        loginFragment=new LoginFragment();
        FragmentTransaction ft=fm.beginTransaction();
        ft.replace(R.id.frame_login_activity,loginFragment);
        ft.commit();
        currentFm=loginFragment;
        Intent intent=getIntent();


    }

    @Override
    public String initToolBarTitle() {
        return null;
    }

    @Override
    public int setMyContentView() {
        return R.layout.activity_login;
    }

    public void toRehisterFm(){
        FragmentTransaction ft=fm.beginTransaction();
        registerFragment=new RegisterFragment();
        ft.add(R.id.frame_login_activity,registerFragment).hide(currentFm);
        ft.addToBackStack(null);
        ft.commit();
        currentFm=registerFragment;
    }
    public void toFindbackpwdFm(){
        FragmentTransaction ft=fm.beginTransaction();
        ft.setCustomAnimations(R.anim.push_left_in
                ,R.anim.push_alpha_in
                , R.anim.push_alpha_out
                ,R.anim.push_left_out);
        Bundle args=new Bundle();
        args.putInt(InterfaceJsonfile.PWDTYPE, 1);
        findbackpwFragment=new FindbackpwFragment();
        findbackpwFragment.setArguments(args);
        ft.add(R.id.frame_login_activity, findbackpwFragment).hide(currentFm);
        ft.addToBackStack(null);
        ft.commit();
        currentFm=findbackpwFragment;
    }
    public void Loginfinish(){
        activity.finish();
    }
}
